using System;
using UnityEngine;
using UnityEngine.EventSystems;
using ZSW.Framework.UIElement;

namespace Main.UI
{
    [RequireComponent(typeof(UI_Slot_Bag))]
    public class UI_ToolTip_Show : ZSWF_BaseUIElement, IPointerEnterHandler, IPointerExitHandler
    {
        private RectTransform rectTransform;
        private UI_Slot_Bag slot;
        private UI_InventorySystem inventorySystem;
        public override void Init()
        {
            base.Init();
            rectTransform = GetComponent<RectTransform>();
            slot = GetComponent<UI_Slot_Bag>();
        }


        public void OnPointerEnter(PointerEventData eventData)
        {
            if (slot.CurrentItemDetails != null)
            {
                inventorySystem.ShowToolTip(slot.CurrentItemDetails, slot.slotType, rectTransform.position);
            }
        }

        public void OnPointerExit(PointerEventData eventData)
        {
            if (slot.CurrentItemDetails != null)
            {
                inventorySystem.HideToolTip();
            }
        }

        public void SetInventoryUI(UI_InventorySystem inventoryUI)
        {
            inventorySystem = inventoryUI;
        }
    }
}

